<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>灯泡开关01</title>
    <style>
        .box{
            width: 300px;
            height: 550px;
            text-align: center;
            margin: 100px auto;
        }
        button{
            outline: none;
            cursor: pointer;
            margin-bottom: 10px;
        }
    </style>
</head>
<body>
    <div class="box">
        <button>开启</button>
        <div>
            <img src="img/pic_bulboff.gif" alt="">
           
        </div>
    </div>
</body>
    <script>
        var btn = document.querySelector('button')
        var imgs = document.querySelector('img')
        btn.onclick = function (){
            if(btn.innerHTML == '开启'){
                imgs.src = "img/pic_bulbon.gif"
                btn.innerHTML = '关闭'
                btn.style.background = '#e5eb35'
            }else{
                imgs.src = "img/pic_bulboff.gif"
                btn.innerHTML = '开启'
                btn.style.background = 'rgb(53,253,66)'
            }
        }
    </script>
</html>


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 300px;
            height: 550px;
            text-align: center;
            margin: 100px auto;
        }
        button{
            margin-bottom: 10px;
        }
    </style>
</head>
